<template>
	<view class="page">
		<!-- <view class="form-item" @click="selectDate">
			<view class="form-title">生日</view>
			<input class="form-value" placeholder="请点击选择生日" v-model="date" :disabled="true" />
		</view> -->
		<!-- <view @click="selectDate">打开</view> -->
		<!-- 生日选择器 -->
		<datePicker ref="pickerRef" @submit="handleBirthdayDate" title="生日选择器" maskColor="rgba(0,0,0,0.3)"
			:defaultDate="defaultDate" :defaultLunar="defaultLunar" />
	</view>
</template>

<script setup>
	import datePicker from '/uni_modules/nj-birthday-picker/components/nj-birthday-picker/nj-birthday-picker.vue'
	import {
		onMounted,
		ref
	} from 'vue';
	let pickerRef = ref('')
	let defaultDate = ref(new Date())
	let defaultLunar = ref(false)
	let dateObj = ref({})
	let date = ref('')
	const selectDate = () => {
		pickerRef.value.show()
	}
	const handleBirthdayDate = (res) => {
		dateObj.value = res;
		if (res.isLunar) {
			date.value = res.lYear + res.gzYear + "年" + res.IMonthCn + res.IDayCn;
		} else {
			date.value = res.date;
		}
		console.log(date.value)
	}
</script>

<style>
	.form-item {
		display: flex;
		align-items: center;
		height: 60px;
		flex-direction: row;
		border-bottom: 1px solid #eee;
	}

	.form-title {
		width: 60px;
		font-size: 18px;
		font-weight: normal;
		color: #333;
	}

	.form-value {
		flex: 1;
		font-size: 18px;
		font-weight: normal;
		color: #333;
	}
</style>